using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;

namespace BlancoWorld.EventReceiversManager 
{
    class EventReceiverBinder
    {
        protected DataTable _eventReceiverPropertyCollection = new DataTable();

        public EventReceiverBinder()
        {
            _eventReceiverPropertyCollection.Columns.Add("PropertyName", typeof(string));
            _eventReceiverPropertyCollection.Columns.Add("PropertyValue", typeof(string));
        }

        public void AddProperty(string PropertyName, string PropertyValue)
        {
            DataRow newRow = _eventReceiverPropertyCollection.Rows.Add();
            newRow["PropertyName"] = PropertyName;
            newRow["PropertyValue"] = PropertyValue;
        }

        public void BindGrid(SPGridView grid)
        {

            SPBoundField fldPropertyName = new SPBoundField();
            fldPropertyName.HeaderText = "Property Name";
            fldPropertyName.DataField = "PropertyName";
            grid.Columns.Add(fldPropertyName);

            SPBoundField fldPropertyValue = new SPBoundField();
            fldPropertyValue.HeaderText = "Value";
            fldPropertyValue.DataField = "PropertyValue";
            grid.Columns.Add(fldPropertyValue);

            grid.AutoGenerateColumns = false;
            grid.DataSource = _eventReceiverPropertyCollection.DefaultView;
            grid.DataBind();
        }
    }
}
